package com.cy.improve.demos.web.xxlJob;

import com.cy.improve.demos.web.mq.MessageProducer;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

import static com.cy.improve.demos.web.xxlJob.utils.LogGenerator.generateSecurityLog;

@Slf4j
@Component
public class GenerateLogJob {


    @Autowired
    private KafkaTemplate<String, String> kafkaTemplate;

    @Autowired
    private MessageProducer messageProducer;


    @XxlJob("SimulateBusinessData")
    // public ReturnT<String> SimulateBusinessData(String param) {
    public void SimulateBusinessData() {
        List<String> list = new ArrayList<>();
        for (int i = 0; i < 100000; i++) {
            String securityLog = generateSecurityLog();
            // log.info(securityLog);
            list.add(securityLog);

        }
        messageProducer.sendMessagesBatch(list, "businesslog");



    }

}
